@extends('layouts.app')

@section('content')
	{{--<div data-options="region:'center'"  class="easy_center">
		<div id="tt" class="easyui-tabs" style="width:100%;" data-options="border:false,fit:true,plain:true">
			<div title="首页"></div>
		</div>
	</div>--}}
	<div class="main-content">
		<div class="search_inp">
			<table width="100%" border="1" class="table_search">
				<thead>
					<tr>
						<th colspan="6">
							<span>查询条件</span>
						</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td width="13.33%" align="right"><label>单位名称：</label></td>
						<td width="20%"><input type="text" class="w150" name="name" placeholder="请输入单位关键字"/></td>
						<td width="13.33%" align="right"><label>联系人：</label></td>
						<td width="20%"><input type="text" class="w150" name="lianxiren" placeholder="请输入联系人全名"/></td>
						<td width="20%">
							<input type="hidden" name="city" value=""/>
							<input type="hidden" name="area" value=""/>
							<input type="hidden" name="org_id" value=""/>
							<a href="javascript:" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:80px" onclick="doSearch()">查询</a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="btn-toolbar list-toolbar">
			<div class="form-all mg_t30">
				<div id="tb">
					{{--@if(Auth::guard('admin')->user()->role_id != 22)
					<a class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">新增</a>
					@endif--}}
					<a class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit()">编辑</a>
					{{--<a class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="jump1()">法人登记</a>
					<a class="easyui-linkbutton" iconCls="icon-bw" plain="true" onclick="jump2()">保安登记</a>
					<a class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="jump3()">提交材料</a>
					<a class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="jump4()">保安公司考核</a>--}}
				</div>
				<table id="dg" title="保安公司列表" class="easyui-datagrid" style="width:100%;height:650px"
						data-options="rownumbers:true,singleSelect:true,pagination:true,pageSize:20,url:'{{url('admin/baoan/index')}}',method:'get',toolbar:'#tb'">
					<thead>
						<tr>
							<th data-options="field:'city'" width="10%" align="center">市</th>
							<th data-options="field:'area'" width="10%" align="center">区</th>
							<th data-options="field:'org_id'" width="10%" align="center">所属派出所</th>
							<th data-options="field:'xingzhi'" width="10%" align="center">企业性质</th>
							<th data-options="field:'name'" width="15%" align="center">单位名</th>
							<th data-options="field:'address'" width="20%" align="center">详细地址</th>
							<th data-options="field:'lianxiren'" width="10%" align="center">联系人</th>
							<th data-options="field:'phone'" width="10%" align="center">联系电话</th>
							<th data-options="field:'is_hege'" width="6%" align="center">是否合格</th>
							{{--<th data-options="field:'id',formatter:formatAction" width="10%" align="center">操作</th>--}}
						</tr>
					</thead>
				</table>
		  </div>
		</div>
	</div>

	<!--注销-->
	<div id="dlg" class="easyui-dialog" title="删除" closed="true" style="width:400px;height:200px;line-height:100px;text-align:center;font-size:16px;padding:10px">
		您确定要删除该单位？
	</div>

	<!--新增-->
	<div id="w" class="easyui-window" closed="true" style="overflow-x: hidden;">
	</div>

	<script type="text/javascript">
		//搜索
		function doSearch(){
			$('#dg').datagrid('load',{
				city: $("input[name='city']").val(),
				area: $("input[name='area']").val(),
				org_id: $("input[name='org_id']").val(),
				name: $("input[name='name']").val(),
				lianxiren: $("input[name='lianxiren']").val(),
			});
		}

		function load_city_data_from_menu($id){
			$('#dg').datagrid('load',{
				city: $id,
			});
			$("input[name='city']").val($id);
			//$("input[name='area']").val('');
			//$("input[name='org_id']").val('');
		}

		function load_area_data_from_menu($id){
			$('#dg').datagrid('load',{
				area: $id,
			});
			//$("input[name='city']").val('');
			$("input[name='area']").val($id);
			//$("input[name='org_id']").val('');
		}
		function load_org_data_from_menu($id){
			$('#dg').datagrid('load',{
				org_id: $id,
			});
			//$("input[name='city']").val('');
			//$("input[name='area']").val('');
			$("input[name='org_id']").val($id);
		}
	</script>
    <script src="{{ URL::asset('/') }}js/weizhi.js"></script>
	<script type="text/javascript">
		var shuz = fb1();
		function add(){
			$('#w').window({
				title: "新增",
				href: 'add',
				width:shuz[0],
				height:shuz[1],
				minimizable:false,
                top:shuz[2],
                left:shuz[3],
				modal:true,
				closed: false,
			});
		}
		function edit(){
			$('#w').html('');
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				var url = 'tab2/'+row.id;
				$('#w').window({
					title: "编辑",
					href: url,
					width:shuz[0],
					height:shuz[1],
					minimizable:false,
	                top:shuz[2],
	                left:shuz[3],
					modal:true,
					closed: false,
					minimizable:false,
				});
			} else {
				$.messager.alert('提示','请选中要编辑的行！');
			}
		}

		function cancel(){
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$('#dlg').dialog({
					title: "删除",
					closed: false,
					modal:true,
					top:($(window).height() - 200) * 0.5,
					left:($(window).width() - 400) * 0.5,
					buttons: [{
						text: '确定',
						iconCls: 'icon-ok',
						handler: del
					}, {
						text: '取消',
						iconCls: 'icon-cancel',
						handler: function () {
							$('#dlg').dialog('close');
						}
					}]
				});
			} else {
				$.messager.alert('提示','请选中要编辑的行！');
			}
		}
		function del(){
			$('#dlg').dialog('close');
			var row = $('#dg').datagrid('getSelected');
			var url = 'del/'+row.id;
			$.ajax({
				type: 'get',
				url: url,
				success: function(data){
					if(data.status == 1){
						$.messager.alert('信息提示',data.msg,'info');
						$('#unit').dialog('close');
						var rowIndex = $('#dg').datagrid('getRowIndex', row);
						$('#dg').datagrid('deleteRow', rowIndex);
					}else{
						$.messager.alert('信息提示',data.msg,'info');
					}
				}
			});
		}

		//法人登记
		function jump1(){
			var row = $('#dg').datagrid('getSelected');
			console.log(row);
			if (row) {
				var url = 'faren/'+row.id;
				$('#w').window({
					title: "法人",
					href: url,
					width:shuz[0],
					height:shuz[1],
					minimizable:false,
	                top:shuz[2],
	                left:shuz[3],
					modal:true,
					closed: false,
					minimizable:false,
				});
			} else {
				$.messager.alert('提示','请选中一条记录！');
			}
		}
		//保安列表
		function jump2(){
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				var url = 'baoan/'+row.id;
				$('#w').window({
					title: "保安列表",
					href: url,
					width:shuz[0],
					height:shuz[1],
					minimizable:false,
	                top:shuz[2],
	                left:shuz[3],
					modal:true,
					closed: false,
					minimizable:false,
				});
			} else {
				$.messager.alert('提示','请选中一条记录！');
			}
		}
		//提交材料
		function jump3(){
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				var url = 'cailiao/'+row.id;
				$('#w').window({
					title: "提交材料",
					href: url,
					width:shuz[0],
					height:shuz[1],
					minimizable:false,
	                top:shuz[2],
	                left:shuz[3],
					modal:true,
					closed: false,
					minimizable:false,
				});
			} else {
				$.messager.alert('提示','请选中一条记录！');
			}
		}

		//保安公司考核
		function jump4(){
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				var url = 'gongsi_kaohe/'+row.id;
				$('#w').window({
					title: "保安公司考核",
					href: url,
					width:shuz[0],
					height:shuz[1],
					minimizable:false,
	                top:shuz[2],
	                left:shuz[3],
					modal:true,
					closed: false,
					minimizable:false,
				});
			} else {
				$.messager.alert('提示','请选中一条记录！');
			}
		}

		$("#dg").datagrid({
			onDblClickRow: function (index, row) {
				edit();
			}
		});
		function export_baoan_company(){
			var city = $("input[name='city']").val();
			var	area = $("input[name='area']").val();
			var org_id = $("input[name='org_id']").val();
			var	name = $("input[name='name']").val();
			var	lianxiren = $("input[name='lianxiren']").val();
			var url = "{{url('admin/baoan/export_baoan_company')}}";
			//window.location.href = url+'?&status='+status+'&major_id='+major_id+'&add_time='+add_time;
			window.location.href = url+'?&city='+city+'&area='+area+'&org_id='+org_id+'&name='+name+'&lianxiren='+lianxiren;
		}
	</script>

@stop
